package com.da.javatest.niuke.jianzhi;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * @author chenlida
 * @date 2020/10/22 10:46
 * https://www.nowcoder.com/practice/6a296eb82cf844ca8539b57c23e6e9bf?
 * tpId=13&tags=&title=&diffculty=0&judgeStatus=0&rp=1
 */
public class C29Solution {
    public ArrayList<Integer> GetLeastNumbers_Solution(int[] input, int k) {
        ArrayList<Integer> list = new ArrayList<>();
        if (k > input.length) {
            return list;
        }
        Arrays.sort(input);
        for (int i = 0; i < k; i++) {
            list.add(input[i]);
        }
        return list;
    }
}
